package com.android.aiod.manager;

import android.content.Context;

import com.android.baselibrary.interface_.OkHttpCallBack;
import com.android.baselibrary.util.Util;
import com.android.aiod.constants.ApiConstants;
import com.lzy.okgo.model.HttpMethod;

import java.util.HashMap;
import java.util.Map;

public class API_Manager {

    //登录
    public static void login(Context context, String phone, String code, OkHttpCallBack<?> callBack) {
        String url =  Config.SERVER_HOST + ApiConstants.login;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("code", code);
        bodyParames.put("phone", phone);
        bodyParames.put("type", 0);
        bodyParames.put("imei", Util.getUUID(context));
         OkHttpManager.okHttpRequest(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack,false);
    }

    //登录
    //unionId =
    //code =
    //openId =
    //nickname = // 昵称
    //avatar =  // 头像
    //gender =  // 性别
    public static void login(Context context, String unionId, String code, String openId, String nickname, String avatar, String gender, OkHttpCallBack<?> callBack) {
        String url =  Config.SERVER_HOST + ApiConstants.login;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("unionId", unionId);
        bodyParames.put("code", code);
        bodyParames.put("openId", openId);
        bodyParames.put("nickname", nickname);
        bodyParames.put("avatar", avatar);
        bodyParames.put("gender", gender);
         OkHttpManager.okHttpRequest(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack,false);
    }


    //unionId =
    //code =
    //openId =
    //userId =
    public static void check_login(Context context, String unionId, String code, String openId, String userId,  OkHttpCallBack<?> callBack) {
        String url =  Config.SERVER_HOST + ApiConstants.login;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("unionId", unionId);
        bodyParames.put("code", code);
        bodyParames.put("openId", openId);
        bodyParames.put("userId", userId);
         OkHttpManager.okHttpRequest(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack,false);
    }








    //发验证码
    public static void sendcode(Context context, String phone, OkHttpCallBack<?> callBack) {
        String url =  Config.SERVER_HOST + ApiConstants.sendcode;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("phone", phone);
        bodyParames.put("type", 0);   //用户类型 0 点点赚用户 1 搜搜看用户
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //我的-页面信息
    public static void mineData(Context context, OkHttpCallBack<?> callBack) {
        String url =  Config.SERVER_HOST + ApiConstants.mine_data;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
         OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //我的-用户信息
    public static void userInfo(Context context, OkHttpCallBack<?> callBack) {
        String url =  Config.SERVER_HOST + ApiConstants.userInfo;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
         OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //填写邀请码
    public static void updateInviteCode(Context context, String inviteCode, OkHttpCallBack<?> callBack) {
        String url =  Config.SERVER_HOST + ApiConstants.updateInviteCode;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("inviteCode", inviteCode);
         OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }


}
